//
//  TokenDef.h
//  LightBasic
//
//  Created by Albert on 24/03/2011.
//  Copyright 2011 LightBasic Development Team. All rights reserved.
//


// Generic tokens
#ifdef TOKEN
    //     name                 string
    TOKEN( Invalid,             "Invalid Token"     )
    TOKEN( EndOfFile,           "End-Of-File"       )
    TOKEN( EndOfStatement,      "End-Of-Statement"  )
    TOKEN( Identifier,          "Identifier"        )
    TOKEN( NumericConstant,     "Number"            )
    TOKEN( StringLiteral,       "String Literal"    )
    #undef TOKEN
#endif


// Operators
#ifdef OPERATOR
    //  RTL    - operator is right to left associative
    //  UNARY  - is unary operator (e.g. -a)
    //  BINARY - is binary operator (e.g. a + b)
    //  lit    - use str literal in lexing or resolve in some other way
    //        id            str     lit,    prec    flags
    OPERATOR( AddressOf,    "@",    true,   900,    RTL | UNARY  )
    OPERATOR( ValueOf,      "*",    0,      900,    RTL | UNARY  )
    OPERATOR( Exponent,     "^",    true,   800,    RTL | BINARY )
    OPERATOR( Negate,       "-",    0,      700,    RTL | UNARY  )
    OPERATOR( Multiply,     "*",    true,   600,    BINARY       )
    OPERATOR( Divide,       "/",    true,   600,    BINARY       )
    OPERATOR( Plus,         "+",    true,   500,    BINARY       )
    OPERATOR( Minus,        "-",    true,   500,    BINARY       )
    OPERATOR( Equal,        "=",    0,      400,    BINARY       )
    OPERATOR( NotEqual,     "<>",   true,   400,    BINARY       )
    OPERATOR( LessThan,     "<",    true,   400,    BINARY       )
    OPERATOR( LessEqal,     "<=",   true,   400,    BINARY       )
    OPERATOR( GreaterEqual, ">=",   true,   400,    BINARY       )
    OPERATOR( GreateThan,   ">",    true,   400,    BINARY       )
    OPERATOR( LogicalNot,   "NOT",  0,      300,    RTL | UNARY  )
    OPERATOR( LogicalAnd,   "AND",  0,      200,    BINARY       )
    OPERATOR( LogicalOr,    "OR",   0,      100,    BINARY       )
    OPERATOR( Assign,       "=",    true,   1,      BINARY       )
    // -1 special precedence for opening brackets.
    // closing brackets *must* have precedence 0
    OPERATOR( ParenOpen,    "(",    true,   0,      0            )
    OPERATOR( ParenClose,   ")",    true,   0,      0            )
    OPERATOR( BracketOpen,  "[",    true,   0,      0            )
    OPERATOR( BracketClose, "]",    true,   0,      0            )
    OPERATOR( AngleOpen,    "<",    0,      0,      0            )
    OPERATOR( AngleClose,   ">",    0,      0,      0            )
    OPERATOR( BraceOpen,    "{",    true,   0,      0            )
    OPERATOR( BraceClose,   "}",    true,   0,      0            )
    // handled seperately
    OPERATOR( Comma,        ",",    true,   0,      0            )
    OPERATOR( Ellipsis,     "...",  true,   0,      0            )
    #undef OPERATOR
#endif


// Operator aliases (keywords)
#ifdef OPERATOR_ALIAS
    // Operator alias keywords - map to operators
    // ID is used for the string as well. so it must match exactly
    //              id      operator
    OPERATOR_ALIAS( NOT,    LogicalNot  )
    OPERATOR_ALIAS( OR,     LogicalOr   )
    OPERATOR_ALIAS( AND,    LogicalAnd  )
    #undef OPERATOR_ALIAS
#endif


// keywords
#ifdef KEYWORD
    //       name
    KEYWORD( ANY        )
    KEYWORD( AS         )
    KEYWORD( CHAR       )
    KEYWORD( DECLARE    )
    KEYWORD( DIM        )
    KEYWORD( VAR        )
    KEYWORD( ELSE       )
    KEYWORD( END        )
    KEYWORD( FUNCTION   )
    KEYWORD( IF         )
    KEYWORD( THEN       )
    KEYWORD( FOR        )
    KEYWORD( INTEGER    )
    KEYWORD( PTR        )
    KEYWORD( RETURN     )
    KEYWORD( SUB        )
    // undefine
    #undef KEYWORD
#endif

    